*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
************************ DRÄGER AND NGHIEM (2025) ***********************
*INFLATION LITERACY, INFLAION EXPECTATIONS, AND TRUST IN THE CENTRAL BANK: 
*                           A SURVEY EXPERIMENT 
****************** THE REVIEW OF ECONOMICS AND STATISTICS ***************
*********************** (REPLICATION FILES) *****************************
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

***********************   JANUARY 2025  *******************************

***** Note: Read "README.txt for details about the code and data ********

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
*** Set STATA
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

*** Clear all ***
clear all
version 18

******************

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
*** Generate main tables of paper
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*


	use "Inflation_literacy_Jan2025_final.dta" , clear

	xtset ID wave

*Table 1: Effect of the Literacy Treatment on Literacy Test Results

	estimate clear
	local controls	"i.age_group college male i.inc_group2 i.employment_group renter hhsize_group East_Germany"
	local target "literacy_grade_inf literacy_fin2"

	foreach y of local target {
	qui: reg `y' basic_treatment `controls' if wave ==1, robust
	qui: estpost margins , dydx(basic_treatment)
	eststo
	}
	
	qui: reg literacy_grade_inf  basic_treatment `controls' if wave ==2, robust
	qui: estpost margins , dydx(basic_treatment)
	eststo
		
	esttab using "Table1.tex", replace style(tex)    b(a2)  numbers nodepvars ///
	star(* 0.10 ** 0.05 *** 0.01) noconstant booktabs not se(2)	 label ///
	title(Effect of Economic Literacy on Economic Literacy Test Results) ///
	stats(r2 N, labels("\text{ R$^2$}" "\text{N observations}") fmt(3 0 0))	

*Table 2: Effect of the Literacy Treatment on Inflation Expectations and Trust in the Central Bank

	estimate clear
	local controls "i.age_group college male i.inc_group2 i.employment_group renter hhsize_group East_Germany"
	local target "inf_perc_point_ans inf_exp1y_point_ans inf_exp3y_point_ans ECB_target_ans"

	
	foreach y of local target {
    qui: probit `y' basic_treatment `controls' if wave == 1
    qui: estpost margins, dydx(basic_treatment)
    qui: estadd scalar r2_p = e(r2_p), replace  // Save Pseudo R^2
    eststo
	}

	local target "inf_perc_point inf_exp1y_point inf_exp3y_point ECB_target"

	foreach y of local target {
    qui: rreg `y' basic_treatment `controls' if wave == 1 & sample_robust_w1_298 == 1
    qui: estpost margins, dydx(basic_treatment)
    qui: estadd scalar r2 = e(r2), replace   // Save R^2
    eststo
	}
	
	local target "trust_ecb trust_bundesbank"

	foreach y of local target {
    qui: reg `y' basic_treatment `controls' if wave == 1 & further_treatment == 0, robust
    qui: estpost margins, dydx(basic_treatment)
    qui: estadd scalar r2 = e(r2), replace   // Save R^2
    eststo
	}

	esttab using "Table2.tex", replace style(tex) b(a2) numbers nodepvars ///
    star(* 0.10 ** 0.05 *** 0.01) noconstant booktabs not se(2) label ///
    title(Effect of the Literacy Treatment on Inflation Expectations and Trust in the Central Bank) ///
    stats(r2_p r2 N, labels("\text{Pseudo R$^2$}" "\text{R$^2$}" "\text{N observations}") fmt(3 3 0))
	
	
*Table 3: Effect of Inflation Literacy on Inflation Expectations and Trust in the Central Bank: IV Regressions
	
	estimate clear
	local controls "i.age_group college male i.inc_group2 i.employment_group renter hhsize_group East_Germany"

	*columns 1 to 4
	local target "inf_perc_point_ans inf_exp1y_point_ans inf_exp3y_point_ans ECB_target_ans"

	qui: reg literacy_grade_inf basic_treatment `controls' if wave == 1
	predict literacy_grade_inf_hat
	test basic_treatment
	local fstat_1 = r(F)  // Extract first-stage F-statistic for columns 1 to 4

	foreach y of local target {
		qui: probit `y' literacy_grade_inf_hat `controls' if wave == 1
		qui: estpost margins, dydx(literacy_grade_inf_hat) predict(pr)
		qui: estadd scalar Fstat = `fstat_1'  // Add F-statistic to the model
		eststo
	}
	drop literacy_grade_inf_hat

	*columns 5 to 8
	qui: reg literacy_grade_inf basic_treatment `controls' if wave == 1 & sample_robust_w1_298 == 1
	predict literacy_grade_inf_hat
	test basic_treatment
	local fstat_2 = r(F)  // Extract first-stage F-statistic for columns 5 to 8

	local target "inf_perc_point inf_exp1y_point inf_exp3y_point ECB_target"

	foreach y of local target {
		qui: rreg `y' literacy_grade_inf_hat `controls' if wave == 1 & sample_robust_w1_298 == 1
		qui: estpost margins, dydx(literacy_grade_inf_hat)
		qui: estadd scalar Fstat = `fstat_2'  // Add F-statistic to the model
		eststo
	}
	drop literacy_grade_inf_hat

	*columns 9 to 10
	qui: reg literacy_grade_inf basic_treatment `controls' if wave == 1 & further_treatment == 0
	predict literacy_grade_inf_hat
	test basic_treatment
	local fstat_3 = r(F)  // Extract first-stage F-statistic for columns 9 to 10

	local target "trust_ecb trust_bundesbank"

	foreach y of local target {
		qui: reg `y' literacy_grade_inf_hat `controls' if wave == 1 & further_treatment == 0, robust
		qui: estpost margins, dydx(literacy_grade_inf_hat)
		qui: estadd scalar Fstat = `fstat_3'  // Add F-statistic to the model
		eststo
	}
	drop literacy_grade_inf_hat

	* Generate the table
	esttab using "Table3.tex", replace style(tex) b(a2) numbers nodepvars ///
    star(* 0.10 ** 0.05 *** 0.01) noconstant booktabs not se(2) label ///
    title(Effect of Inflation Literacy on Inflation Expectations and Trust in the Central Bank: IV Regressions) ///
    stats(Fstat N, labels("\text{First-stage F-statistic}" "\text{N observations}") fmt(2 0))

*Table 4: Interaction Effects of the Literacy Treatment and Quantitative Information Treatments
	
	estimate clear
	local controls	" i.age_group college male i.inc_group2 i.employment_group renter hhsize_group East_Germany"
	local target "inf_exp1y inf_exp3y"
	drop inf_prior
	
	foreach y of local target {
	gen inf_prior = `y'_point
	
	qui: rreg `y'_prob inf_prior i.basic_treatment##i.further_treatment  `controls' if wave== 1 & sample_robust_w1_298 == 1, gen(hw_prob_`y')
	qui: estpost  
	eststo
	drop inf_prior
	}
	

	foreach y of local target {
	gen inf_prior = `y'_point
	
	qui: rreg `y'_var inf_prior i.basic_treatment##i.further_treatment  `controls' if wave== 1 & sample_robust_w1_298 == 1, gen(hw_var_`y')
	qui: estpost  
	eststo
	drop inf_prior
	}
	
	local target "trust_ecb trust_bundesbank"
	
	foreach y of local target {
	gen inf_prior = inf_exp3y_point	
		
	qui: reg `y' inf_prior i.basic_treatment##i.further_treatment `controls' if wave == 1 & sample_robust_w1_298 == 1, robust
	qui: estpost  
	eststo
	drop inf_prior
	}

	
	esttab using "Table4.tex", replace style(tex)    b(a2)  numbers nodepvars ///
	 star(* 0.10 ** 0.05 *** 0.01) noconstant booktabs not se(2)	 label ///
	 title(Interaction Effects of the Literacy Treatment and Quantitative Information Treatments) ///
	stats(r2 N, labels("\text{R$^2$}" "\text{N observations}") fmt(3 0 0))
	
********************************************************************************
********************************************************************************


	
	
	